#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define kMaxNameLen 10
typedef char ElemSet[kMaxNameLen + 1]; /* 默认元素为字符串*/
typedef int Position; /* 数组下标是元素的位置 */
typedef enum {Unknown, GanLaji, ShiLaji, KeHuiShou, YouHaiLaji} Type;
typedef struct RecordNode {
    ElemSet key; /* 关键字：物品名称 */
    Type type; /* 垃圾分类 */
} Records;
#define kMaxN 100000

Position BinarySearch(Records record[], int low, int high, ElemSet key) {
    /* 注意：元素下标从1开始 */
    Position pos, mid;

    pos = 0; /* 第0个位置设为岗哨 */
    if (low <= high) {
        mid = (low + high) >> 1;
        if (strcmp(key, record[mid].key) < 0) {
            /* key < record[mid].key */
            pos = BinarySearch(record, low, mid - 1, key);
        } else if (strcmp(key, record[mid].key) > 0) {
            /* key > record[mid].key */
            pos = BinarySearch(record, mid + 1, high, key);
        } else { /* key = record[mid].key */
            pos = mid;
        }
    }
    return pos;
}

int CmpName(const void *a, const void *b) {
    return strcmp(((const Records*)a)->key, ((const Records*)b)->key);
}

void Output(Type type) {
    switch (type) {
    case GanLaji:
        printf("Gan laji\n");
        break;
    case ShiLaji:
        printf("Shi laji\n");
        break;
    case KeHuiShou:
        printf("Ke Hui Shou\n");
        break;
    case YouHaiLaji:
        printf("You Hai laji\n");
        break;
    default:
        printf("?\n");
        break;
    }
}

int main() {
    Records *items;
    ElemSet query;
    int n, i;

    scanf("%d\n", &n);
    items = (Records *)malloc(sizeof(Records) * (n + 1));
    /* 第0个位置设为岗哨，数据从下标1开始 */
    items[0].type = Unknown; /* 哨兵类型为“不知道”*/
    for (i = 1; i <= n; i++) {
        scanf("%s %d\n", items[i].key, &items[i].type);
    }
    qsort(items + 1, n, sizeof(Records), CmpName);
    scanf("%s\n", query);
    while (query[0] != '#') {
        i = BinarySearch(items, 1, n, query);
        Output(items[i].type);
        scanf("%s\n", query);
    }

    return 0;
}